package com.wanmait.wisdom.manage.controller;

import com.wanmait.wisdom.entity.Complaint;
import com.wanmait.wisdom.entity.Rapair;
import com.wanmait.wisdom.manage.service.ManageRapairService;
import com.wanmait.wisdom.util.AjaxResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;

@RestController
@RequestMapping("/manage")
public class ManageRapairController {
    @Resource
    private ManageRapairService manageRapairService;

    @GetMapping("/getRapairFinishedCount")
    public AjaxResult getRapairFinishedCount(){
        return AjaxResult.success(manageRapairService.getRapairFinishedCount());
    }

    @GetMapping("getRapairUnFinishedCount")
    public AjaxResult getRapairUnFinishedCount(){
        return AjaxResult.success(manageRapairService.getRapairUnFinishedCount());
    }

    @PostMapping("searchRapairByCondition")
    public AjaxResult searchRapairByCondition(@RequestBody Rapair rapair, Integer pageNum, Date startTime, Date endTime){
        System.out.println(rapair.getProcessingStatus());
        if (pageNum==null){
            pageNum =1;
        }
        return AjaxResult.success(manageRapairService.searchRapairByCondition(rapair,pageNum,startTime,endTime,5));
    }

    @GetMapping("/selectRapairById")
    public AjaxResult selectRapairById(Rapair rapair){
        return AjaxResult.success(manageRapairService.selectRapairById(rapair.getId()));
    }
    @PostMapping("/updateRapair")
    public AjaxResult updateRapair(@RequestBody Rapair rapair){
        System.out.println(rapair);
        rapair.setProcessingStatus(true);
        return AjaxResult.success(manageRapairService.updateRapair(rapair));
    }



}
